syntax = "proto3";

import "collections.proto";

package qdrant;
option csharp_namespace = "Qdrant.Client.Grpc";

service CollectionsInternal {
  /*
  Get collection info
  */
  rpc Get (GetCollectionInfoRequestInternal) returns (GetCollectionInfoResponse) {}
  /*
  Initiate shard transfer
  */
  rpc Initiate (InitiateShardTransferRequest) returns (CollectionOperationResponse) {}
  /**
  Wait for a shard to get into the given state
  */
  rpc WaitForShardState (WaitForShardStateRequest) returns (CollectionOperationResponse) {}
  /*
  Get shard recovery point
  */
  rpc GetShardRecoveryPoint (GetShardRecoveryPointRequest) returns (GetShardRecoveryPointResponse) {}
  /*
  Update shard cutoff point
  */
  rpc UpdateShardCutoffPoint (UpdateShardCutoffPointRequest) returns (CollectionOperationResponse) {}
}

message GetCollectionInfoRequestInternal {
  GetCollectionInfoRequest get_collectionInfoRequest = 1;
  uint32 shard_id = 2;
}

message InitiateShardTransferRequest {
  string collection_name = 1; // Name of the collection
  uint32 shard_id = 2; // Id of the temporary shard
}

message WaitForShardStateRequest {
  string collection_name = 1; // Name of the collection
  uint32 shard_id = 2; // Id of the shard
  ReplicaState state = 3;  // Shard state to wait for
  uint64 timeout = 4; // Timeout in seconds
}

message GetShardRecoveryPointRequest {
  string collection_name = 1; // Name of the collection
  uint32 shard_id = 2; // Id of the shard
}

message GetShardRecoveryPointResponse {
  RecoveryPoint recovery_point = 1; // Recovery point of the shard
  double time = 2; // Time spent to process
}

message RecoveryPoint {
  repeated RecoveryPointClockTag clocks = 1;
}

message RecoveryPointClockTag {
  uint64 peer_id = 1;
  uint32 clock_id = 2;
  uint64 clock_tick = 3;
  uint64 token = 4;
}

message UpdateShardCutoffPointRequest {
  string collection_name = 1; // Name of the collection
  uint32 shard_id = 2; // Id of the shard
  RecoveryPoint cutoff = 3; // Cutoff point of the shard
}
